*************************************************************
* The following code is part of the gkm_replication_isq archive of  * 
* Genovese, Kern & Martin (2016) "Policy Alternation", ISQ  * 
*************************************************************

********
* 2002 *
********

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy"
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/EU neighbors_carbon policy.dta", clear

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps"
drop if year!=2002
saveold "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2002.dta", replace
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2002.dta", clear

merge countryn using transRG, sort unique
drop _merge
merge id using RGdb, sort unique

* Include other EU countries for better  visualization

* In order: Germany, UK, Greece, Italy, Netherlands, Luxembourg, Denmark, Albania, Serbia, Sweden, Ireland, Finland
replace _merge = 3 in 68
replace _merge = 3 in 221
replace _merge = 3 in 77
replace _merge = 3 in 114
replace _merge = 3 in 165
replace _merge = 3 in 137
replace _merge = 3 in 70
replace _merge = 3 in 24
replace _merge = 3 in 185
replace _merge = 3 in 192
replace _merge = 3 in 107
replace _merge = 3 in 81
*France below - the colonies make it weird
* replace _merge = 3 in 86
*Spain
* replace _merge = 3 in 79
*portugal
* replace _merge = 3 in 181

drop if _merge!=3

spmap co2tax_impl using RGcoord, id(id) fcolor(ltblue*1.2 navy*.9) legenda(on) legend(label(3 "Co2 Tax") label(2 "No Co2 Tax") label(1 " ")) caption("2002") saving(otax2, replace)
generate shade = !inlist(id,22,41,53,54,62,93,95,104,128,130,146,160,172,181,192,194,215)
spmap shade using RGcoord, id(id) clmethod(unique)  fcolor("255 219 190" white red) legend(label(2 "No Co2 Trade") label(3 " ")) caption("2002") saving(otrade2, replace)

clear

********
* 2004 *
********

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy"
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/EU neighbors_carbon policy.dta", clear

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps"
drop if year!=2004
saveold "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2004.dta", replace
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2004.dta", clear

merge countryn using transRG, sort unique
drop _merge
merge id using RGdb, sort unique

* Include other EU countries for better  visualization

* In order: Germany, UK, Greece, Italy, Netherlands, Luxembourg, Denmark, Albania, Serbia, Sweden, Ireland, Finland
replace _merge = 3 in 68
replace _merge = 3 in 221
replace _merge = 3 in 77
replace _merge = 3 in 114
replace _merge = 3 in 165
replace _merge = 3 in 137
replace _merge = 3 in 70
replace _merge = 3 in 24
replace _merge = 3 in 185
replace _merge = 3 in 192
replace _merge = 3 in 107
replace _merge = 3 in 81
*France below - the colonies make it weird
* replace _merge = 3 in 86
*Spain
* replace _merge = 3 in 79
*portugal
* replace _merge = 3 in 181

drop if _merge!=3

spmap co2tax_impl using RGcoord, id(id) fcolor(ltblue*1.2 navy*.9) legenda(on) legend(label(3 "Co2 Tax") label(2 "No Co2 Tax") label(1 " ")) caption("2004") saving(otax4, replace)
spmap co2trade_allowance_impl using RGcoord, id(id) fcolor(Reds) legenda(on) legend(label(3 "Co2 Trade") label(2 "No Co2 Trade") label(1 " ")) caption("2004") saving(otrade4, replace)

clear


********
* 2006 *
********

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy"
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/EU neighbors_carbon policy.dta", clear

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps"
drop if year!=2006
saveold "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2006.dta", replace
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2006.dta", clear

merge countryn using transRG, sort unique
drop _merge
merge id using RGdb, sort unique

* Include other EU countries for better  visualization

* In order: Germany, UK, Greece, Italy, Netherlands, Luxembourg, Denmark, Albania, Serbia, Sweden, Ireland, Finland
replace _merge = 3 in 68
replace _merge = 3 in 221
replace _merge = 3 in 77
replace _merge = 3 in 114
replace _merge = 3 in 165
replace _merge = 3 in 137
replace _merge = 3 in 70
replace _merge = 3 in 24
replace _merge = 3 in 185
replace _merge = 3 in 192
replace _merge = 3 in 107
replace _merge = 3 in 81
*France below - the colonies make it weird
* replace _merge = 3 in 86
*Spain
* replace _merge = 3 in 79
*portugal
* replace _merge = 3 in 181

drop if _merge!=3

spmap co2tax_impl using RGcoord, id(id) fcolor(ltblue*1.2 navy*.9) legenda(on) legend(label(3 "Co2 Tax") label(2 "No Co2 Tax") label(1 " ")) caption("2006") saving(otax6, replace)
spmap co2trade_allowance_impl using RGcoord, id(id) fcolor(Reds) legenda(on) legend(label(3 "Co2 Trade") label(2 "No Co2 Trade") label(1 " ")) caption("2006") saving(otrade6, replace)

clear


********
* 2008 *
********

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy"
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/EU neighbors_carbon policy.dta", clear

cd "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps"
drop if year!=2008
saveold "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2008.dta", replace
use "/Users/genovesefederica/Dropbox/Diffusion vs. Osmosis/gkm_replication_isq/carbon policy/Appendix/Maps/Dataframe_2008.dta", clear

merge countryn using transRG, sort unique
drop _merge
merge id using RGdb, sort unique

* Include other EU countries for better  visualization

* In order: Germany, UK, Greece, Italy, Netherlands, Luxembourg, Denmark, Albania, Serbia, Sweden, Ireland, Finland
replace _merge = 3 in 68
replace _merge = 3 in 221
replace _merge = 3 in 77
replace _merge = 3 in 114
replace _merge = 3 in 165
replace _merge = 3 in 137
replace _merge = 3 in 70
replace _merge = 3 in 24
replace _merge = 3 in 185
replace _merge = 3 in 192
replace _merge = 3 in 107
replace _merge = 3 in 81
*France below - the colonies make it weird
* replace _merge = 3 in 86
*Spain
* replace _merge = 3 in 79
*portugal
* replace _merge = 3 in 181

drop if _merge!=3

spmap co2tax_impl using RGcoord, id(id) fcolor(ltblue*1.2 navy*.9) legenda(on) legend(label(3 "Co2 Tax") label(2 "No Co2 Tax") label(1 " "))  caption("2008") saving(otax8, replace)
spmap co2trade_allowance_impl using RGcoord, id(id) fcolor("255 219 190" red) legenda(on) legend(label(3 "Co2 Trade") label(2 "No Co2 Trade") label(1 " ")) caption("2008") saving(otrade8, replace)

clear

